/**
 * 
 */
package leetCode;

import java.awt.CardLayout;
import java.util.HashMap;
import java.util.Map;

/**
 * @author zhongfang
 *
 */
public class TaskScheduler {
    public int leastInterval(char[] tasks, int n) {
    	HashMap<Character, Integer> freq=new HashMap<>();
        for (int i = 0; i < tasks.length; i++) {
			freq.put(tasks[i], freq.getOrDefault(tasks[i], 0)+1);
		}
        
        int max=0,maxCount=0;
        for (Integer integer : freq.values()) {
			if(integer>max){
				max=integer;
				maxCount=0;
			}else if (integer==max) {
				maxCount++;
			}
		}
        return max;
    }
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
